package cn.bugstack.types.design.framework.link.model2;

import cn.bugstack.types.design.framework.link.model2.chain.BusinessLinkedList;
import cn.bugstack.types.design.framework.link.model2.handler.ILogicHandler;

/**
 * @description 多例责任链，只要创建多个对象，就可以获得相同或者不同的责任链，相互之间不影响
 * 链路装配，
 */
public class LinkArmory<T, D, R> {

    private final BusinessLinkedList<T, D, R> logicLink;

    // 初始化一个责任链
    @SafeVarargs      // 责任链名称          逻辑处理器       参数数量不定
    public LinkArmory(String linkName, ILogicHandler<T, D, R>... logicHandlers) {
        logicLink = new BusinessLinkedList<>(linkName);
        for (ILogicHandler<T, D, R> logicHandler: logicHandlers){
            logicLink.add(logicHandler);
        }
    }

    // 返回装配好的责任链
    public BusinessLinkedList<T, D, R> getLogicLink() {
        return logicLink;
    }

}
